#ifndef __GD32E23x_HAL_MOTOR_CTRL_H__
#define __GD32E23x_HAL_MOTOR_CTRL_H__

#include <stdint.h>

#define MOTOR_CTRL_RCU      RCC_AHBPeriph_GPIOA
#define MOTOR_CTRL_BASE     GPIOA

#define MOTOR_CTRL_RUN      GPIO_Pin_15
#define MOTOR_CTRL_DOWN     GPIO_Pin_11
#define MOTOR_CTRL_UP       GPIO_Pin_12

#define MOTOR_SEQUENCE_RCU      RCC_AHBPeriph_GPIOB
#define MOTOR_SEQUENCE_BASE     GPIOB
#define MOTOR_SEQUENCE_PIN		GPIO_Pin_4

#define MOTOR_STATE_STOP      	(0)
#define MOTOR_STATE_DOWN    	(1)
#define MOTOR_STATE_UP      	(2)

typedef struct motor_ctrl {
    void (*init)(void);         //初始化
    int (*setting)(int speed_set,int timeout);    //电机设置
    void (*ctrl_up)(void);              //控制上
    void (*ctrl_down)(void);            //控制下
    void (*ctrl_run)(uint8_t flag);     //控制运行 1:run 0:stop
    uint32_t (*run_time)(void);         //运行时间
    void (*get_status)(uint8_t *run,uint8_t *state);    //获得运行状态
	uint8_t (*get_phase_sequence)(void);				//获得相序
}motor_ctrl_t;

extern const motor_ctrl_t g_motor_;

#endif//__GD32E23x_HAL_MOTOR_CTRL_H__
